package com.kexio.user.entity;

import java.time.LocalDateTime;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.kexio.common.entity.BaseEntity;

/**
 * 用户角色关联实体
 * 
 * 对应数据库表 sys_user_role
 * 存储用户与角色的多对多关系及分配信息
 * 
 * @author kexio
 * @since 1.0.0
 */
@TableName("sys_user_role")
public class UserRole extends BaseEntity {
    
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private String id;
    
    /**
     * 用户ID
     */
    @TableField("user_id")
    private String userId;
    
    /**
     * 角色ID
     */
    @TableField("role_id")
    private String roleId;
    
    /**
     * 分配时间
     */
    @TableField("assigned_at")
    private LocalDateTime assignedAt;
    
    /**
     * 分配人（用户ID）
     */
    @TableField("assigned_by")
    private String assignedBy;
    
    /**
     * 分配类型：MANUAL-手动分配, AUTO-自动分配, INHERIT-继承分配
     */
    @TableField("assigned_type")
    private String assignedType;
    
    // ==================== Getters and Setters ====================
    
    public String getId() { 
        return id; 
    }
    
    public void setId(String id) { 
        this.id = id; 
    }
    
    public String getUserId() { 
        return userId; 
    }
    
    public void setUserId(String userId) { 
        this.userId = userId; 
    }
    
    public String getRoleId() { 
        return roleId; 
    }
    
    public void setRoleId(String roleId) { 
        this.roleId = roleId; 
    }
    
    public LocalDateTime getAssignedAt() { 
        return assignedAt; 
    }
    
    public void setAssignedAt(LocalDateTime assignedAt) { 
        this.assignedAt = assignedAt; 
    }
    
    public String getAssignedBy() { 
        return assignedBy; 
    }
    
    public void setAssignedBy(String assignedBy) { 
        this.assignedBy = assignedBy; 
    }
    
    public String getAssignedType() { 
        return assignedType; 
    }
    
    public void setAssignedType(String assignedType) { 
        this.assignedType = assignedType; 
    }
    
    // ==================== ToString ====================
    
    @Override
    public String toString() {
        return "UserRole{" +
                "id='" + id + '\'' +
                ", userId='" + userId + '\'' +
                ", roleId='" + roleId + '\'' +
                ", assignedAt=" + assignedAt +
                ", assignedBy='" + assignedBy + '\'' +
                ", assignedType='" + assignedType + '\'' +
                ", " + super.toString() +
                '}';
    }
}